Have you get a solution? i have the same problem too, golang is not compatible with java SecretKeyFactory
在 2015年12月2日星期三 UTC+8上午7:47:22,Jeff写道: > > I'm am looking to implement in go, the following code written in Java. > I have not been able to find any apis or modules for this. Is it > possible to achieve this, did I just not the right resources? How are we > doing secure hashing in go? > Thanks. > > /** > * Encrypts the given password with a salt > * > * @param password The password string to be encrypted > * @param salt A randomly generated salt for the password > encryption > * @return The byte[] containing the encrypted password > * @throws NoSuchAlgorithmException > * @throws InvalidKeySpecException > */ > public static byte[] getEncryptedPassword(String password, byte[] salt) > throws NoSuchAlgorithmException, InvalidKeySpecException { > String algorithm = "PBKDF2WithHmacSHA1"; > int derivedKeyLength = 160; > // The NIST recommends at least 1,000 iterations: > // > http://csrc.nist.gov/publications/nistpubs/800-132/nist-sp800-132.pdf > int iterations = 20000; > > KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, > iterations, derivedKeyLength); > > SecretKeyFactory f = SecretKeyFactory.getInstance(algorithm); > > return f.generateSecret(spec).getEncoded(); > } > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.