Integers.cs 693 B

123456789101112131415161718192021222324252627
  1. using System;
  2. namespace Renci.SshNet.Security.Org.BouncyCastle.Utilities
  3. {
  4. internal abstract class Integers
  5. {
  6. public static int RotateLeft(int i, int distance)
  7. {
  8. return (i << distance) ^ (int)((uint)i >> -distance);
  9. }
  10. public static uint RotateLeft(uint i, int distance)
  11. {
  12. return (i << distance) ^ (i >> -distance);
  13. }
  14. public static int RotateRight(int i, int distance)
  15. {
  16. return (int)((uint)i >> distance) ^ (i << -distance);
  17. }
  18. public static uint RotateRight(uint i, int distance)
  19. {
  20. return (i >> distance) ^ (i << -distance);
  21. }
  22. }
  23. }