FAQ
"My question for the original poster is whether he needs to maintain
compatibility with a legacy system, or whether he is looking for a good
system when starting from scratch."

it will be a new system that will import existing records, which will have
already hashed user passwords.

On Tuesday, December 1, 2015 at 4:47:22 PM UTC-7, Jeff wrote:

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 8 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 1, '15 at 11:47p
activeDec 4, '15 at 11:09p
posts8
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase