JXMovies/Core/JXCMS.Core/Encrypt/SupportClass.cs

55 lines
2.0 KiB
C#
Raw Permalink Normal View History

2020-02-09 19:10:05 +08:00
namespace JXCMS.Core.Encrypt
{
public class SupportClass
{
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
///<param name="number">Number to operate on
///<param name="bits">Ammount of bits to shift
/// <returns>The resulting number from the shift operation</returns>
public static int URShift(int number, int bits)
{
if (number >= 0)
return number >> bits;
else
return (number >> bits) + (2 << ~bits);
}
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
///<param name="number">Number to operate on
///<param name="bits">Ammount of bits to shift
/// <returns>The resulting number from the shift operation</returns>
public static int URShift(int number, long bits)
{
return URShift(number, (int)bits);
}
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
///<param name="number">Number to operate on
///<param name="bits">Ammount of bits to shift
/// <returns>The resulting number from the shift operation</returns>
public static long URShift(long number, int bits)
{
if (number >= 0)
return number >> bits;
else
return (number >> bits) + (2L << ~bits);
}
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number
/// </summary>
///<param name="number">Number to operate on
///<param name="bits">Ammount of bits to shift
/// <returns>The resulting number from the shift operation</returns>
public static long URShift(long number, long bits)
{
return URShift(number, (int)bits);
}
}
}