Time-based one-time password algorithm: Difference between revisions

Content deleted Content added
mNo edit summary
m Add 'GenerateSecret' method
Line 91: Line 91:
}
}
Quit str
Quit str
}

ClassMethod GenerateSecret() As %String
{
// initialise base 32 string and alphabet
Set b32str="", b32alp="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
// build a large base 32 string
For pass=1:1:4 {
Set b32str=b32str_..ConvertBase10ToN($System.Encryption.GenCryptToken(), 32, b32alp)
}
// return randomly generated password
Quit ..LeftPad(b32str, 16)
}
}


Line 103: Line 117:
169898
169898
487462
487462

DEMO>write ##class(User.View.Security).GenerateSecret()
5FWQZLQVXIBCKKMJ
DEMO>write ##class(User.View.Security).GenerateSecret()
M4AKQBFI252H4BWO
</pre>
</pre>