本文整理匯總了C#中Algorithm.generateHash方法的典型用法代碼示例。如果您正苦於以下問題:C# Algorithm.generateHash方法的具體用法?C# Algorithm.generateHash怎麽用?C# Algorithm.generateHash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Algorithm
的用法示例。
在下文中一共展示了Algorithm.generateHash方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: receiveChallenge
/// <summary> Initiator API
/// Receive Challenge, respond with a hash.
/// </summary>
//UPGRADE_NOTE: Synchronized keyword was removed from method 'receiveChallenge'. Lock expression was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1027"'
internal virtual void receiveChallenge(Blob blob)
{
lock (this)
{
log.debug("OTP Authenticator received Challenge");
// If we're initiating, the last state we should
// have gotten to was STATE_STARTED
if (state != STATE_STARTED)
{
abortNoThrow(ERR_OTP_STATE);
}
if (blob.Status.Equals(Blob.ABORT))
{
abort(ERR_PEER_ABORTED);
}
System.String challenge = blob.Data;
// Parse Challenge, provide response
state = STATE_CHALLENGE;
int sequence = 0;
System.String seed = null, algo = null;
if (log.isDebugEnabled())
{
log.debug("Tokenizing=>" + challenge);
}
SupportClass.Tokenizer st = new SupportClass.Tokenizer(challenge);
if (st.Count != 4)
{
abort("Failed to understand server's Challenge" + st.Count);
}
algo = st.NextToken();
algorithm = SASLOTPProfile.getAlgorithm(algo);
if (algorithm == null)
{
abort("Unrecognized algorithm in server challenge");
}
sequence = System.Int32.Parse(st.NextToken());
seed = st.NextToken().ToLower();
if (!OTPGenerator.validateSeed(seed))
abort("Invalid Seed");
if (log.isDebugEnabled())
{
log.debug("Algo is=>" + algo + " seed is=>" + seed + " seq=>" + sequence);
}
System.String phrase = new System.Text.StringBuilder(seed + password).ToString();
password = null;
sbyte[] response = null, temp;
temp = SupportClass.ToSByteArray(SupportClass.ToByteArray(phrase));
for (int i = 0; i < sequence; i++)
{
response = algorithm.generateHash(temp);
temp = response;
}
if (log.isDebugEnabled())
{
log.debug(SASLOTPProfile.convertBytesToHex(temp));
}
long l = profile.convertBytesToLong(temp);
phrase = new System.Text.StringBuilder(WORD + OTPDictionary.convertHashToWords(l)).ToString();
if (log.isDebugEnabled())
{
log.debug("Prelim response is =>" + phrase + "<=");
}
// IF this is an init request
if ((System.Object) initData != null)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(128);
sb.Append(SASLOTPProfile.HEX_INIT);
sb.Append(SASLOTPProfile.convertBytesToHex(temp));
sb.Append(initData);
phrase = sb.ToString();
if (log.isDebugEnabled())
{
log.debug("Produced INIT response of " + phrase);
}
}
try
{
blob = new Blob(Blob.STATUS_CONTINUE, phrase);
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
//.........這裏部分代碼省略.........