我想將使用C#編寫的應用程序移植到Ruby,並且我無法理解幾個函數。C#的IncrementArray和Array.Copy函數
這是代碼。
for (int pos = 0; pos < EncryptedData.Length; pos += AesKey.Length)
{
Array.Copy(incPKGFileKey, 0, PKGFileKeyConsec, pos, PKGFileKey.Length);
IncrementArray(ref incPKGFileKey, PKGFileKey.Length - 1);
}
private Boolean IncrementArray(ref byte[] sourceArray, int position)
{
if (sourceArray[position] == 0xFF)
{
if (position != 0)
{
if (IncrementArray(ref sourceArray, position - 1))
{
sourceArray[position] = 0x00;
return true;
}
else return false;
}
else return false;
}
else
{
sourceArray[position] += 0x01;
return true;
}
}
我知道陣列和密鑰的長度是16 我將不勝感激,如果有人可以解釋Array.Copy和IncrementArray功能是如何工作的。
我已經從源代碼中添加了IncrementArray函數,我希望有一些幫助解釋它。 – user2053979 2013-02-14 00:24:30