You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.go 758B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2015 Kohei YOSHIDA. All rights reserved.
  2. // This software is licensed under the 3-Clause BSD License
  3. // that can be found in LICENSE file.
  4. package internal
  5. const (
  6. cleanBytesLen = 64
  7. )
  8. var (
  9. cleanBytes = make([]byte, cleanBytesLen)
  10. )
  11. func CleanSensitiveData(b []byte) {
  12. l := len(b)
  13. for ; l > cleanBytesLen; l -= cleanBytesLen {
  14. copy(b[l-cleanBytesLen:l], cleanBytes)
  15. }
  16. if l > 0 {
  17. copy(b[0:l], cleanBytes[0:l])
  18. }
  19. }
  20. func RepeatByteSequence(input []byte, length int) []byte {
  21. var (
  22. sequence = make([]byte, length)
  23. unit = len(input)
  24. )
  25. j := length / unit * unit
  26. for i := 0; i < j; i += unit {
  27. copy(sequence[i:length], input)
  28. }
  29. if j < length {
  30. copy(sequence[j:length], input[0:length-j])
  31. }
  32. return sequence
  33. }