简体   繁体   中英

How to generate octet string in Java?

I want to set password in active directory using using java/spring ldap api. AD schema for attribut userPassword says Octet string. How can I generate any password to octet string ?

If I have password "tempPassword" - how can I convert to octet string ?

Octet string are just bytes:

byte[] octetString = "tempPassword".getBytes(StandardCharsets.US_ASCII);
System.out.println(new BigInteger(1, octetString).toString(16));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM