-5

I need to convert following code to Swift

static const char gSalt[] =
    {
        (unsigned char)0xf4, (unsigned char)0x28, (unsigned char)0x32, (unsigned char)0xab,
        (unsigned char)0x4b, (unsigned char)0xa1, (unsigned char)0xcc, (unsigned char)0x43
    };
vacawama
  • 150,663
  • 30
  • 266
  • 294
Muhammad Aamir Ali
  • 20,419
  • 10
  • 66
  • 57

1 Answers1

1

In Swift, a UInt8 is the corresponding type to C's unsigned char, so this would create a constant array of UInt8 values:

let gSalt:[UInt8] = [0xf4, 0x28, 0x32, 0xab, 0x4b, 0xa1, 0xcc, 0x43]

In Swift, you should just declare this in whatever scope you need it. If it is only needed by the methods of a single class, then declare this in that class. If you need it globally, then declare it outside of any class.

vacawama
  • 150,663
  • 30
  • 266
  • 294