"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?

* Encrypts the given password with a salt
* @param password The password string to be encrypted
* @param salt A randomly generated salt for the password
* @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:
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


Follow ups

Related Discussions

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



site design / logo © 2021 Grokbase