Thứ Hai, 18 tháng 2, 2019

How to use dbms_crypto

DECLARE
    input_string     VARCHAR2(16) := 'tigertigertigert';
    raw_input        RAW(128) :=
UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    key_string       VARCHAR2(8)  := 'scottsco';
    raw_key          RAW(128) :=
UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
    encrypted_raw    RAW(2048);
    encrypted_string VARCHAR2(2048);
    decrypted_raw    RAW(2048);
    decrypted_string VARCHAR2(2048); 
-- Begin testing Encryption: 
BEGIN
    dbms_output.put_line('> Input String                     : ' || 
    CONVERT(UTL_RAW.CAST_TO_VARCHAR2(raw_input),'US7ASCII','AL32UTF8'));
    dbms_output.put_line('> ========= BEGIN TEST Encrypt =========');
    encrypted_raw := dbms_crypto.Encrypt(
        src => raw_input, 
        typ => DBMS_CRYPTO.DES_CBC_PKCS5, 
        key => raw_key);
        dbms_output.put_line('> Encrypted hex value              : ' || 
        rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_raw)));
decrypted_raw := dbms_crypto.Decrypt(
        src => encrypted_raw, 
        typ => DBMS_CRYPTO.DES_CBC_PKCS5, 
        key => raw_key);
    decrypted_string := 
    CONVERT(UTL_RAW.CAST_TO_VARCHAR2(decrypted_raw),'US7ASCII','AL32UTF8');
dbms_output.put_line('> Decrypted string output          : ' || 
        decrypted_string);
if input_string = decrypted_string THEN
    dbms_output.put_line('> String DES Encyption and Decryption successful');
END if;
dbms_output.put_line('');
dbms_output.put_line('> ========= BEGIN TEST Hash =========');
    encrypted_raw := dbms_crypto.Hash(
        src => raw_input, 
        typ => DBMS_CRYPTO.HASH_SH1);
dbms_output.put_line('> Hash value of input string       : ' || 
        rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_raw)));
dbms_output.put_line('> ========= BEGIN TEST Mac =========');
    encrypted_raw := dbms_crypto.Mac(
        src => raw_input, 
        typ => DBMS_CRYPTO.HMAC_MD5, 
        key => raw_key);
dbms_output.put_line('> Message Authentication Code      : ' || 
        rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_raw)));
dbms_output.put_line('');
dbms_output.put_line('> End of DBMS_CRYPTO tests  ');
END;
/


Source: https://docs.oracle.com/database/121/DBSEG/data_encryption.htm#DBSEG335

Chủ Nhật, 7 tháng 5, 2017

Country code enum

UNKNOWN = 0,
AP = 1,
EU = 2,
AD = 3,
AE = 4,
AF = 5,
AG = 6,
AI = 7,
AL = 8,
AM = 9,
CW = 10,
AO = 11,
AQ = 12,
AR = 13,
AS = 14,
AT = 15,
AU = 16,
AW = 17,
AZ = 18,
BA = 19,
BB = 20,
BD = 21,
BE = 22,
BF = 23,
BG = 24,
BH = 25,
BI = 26,
BJ = 27,
BM = 28,
BN = 29,
BO = 30,
BR = 31,
BS = 32,
BT = 33,
BV = 34,
BW = 35,
BY = 36,
BZ = 37,
CA = 38,
CC = 39,
CD = 40,
CF = 41,
CG = 42,
CH = 43,
CI = 44,
CK = 45,
CL = 46,
CM = 47,
CN = 48,
CO = 49,
CR = 50,
CU = 51,
CV = 52,
CX = 53,
CY = 54,
CZ = 55,
DE = 56,
DJ = 57,
DK = 58,
DM = 59,
DO = 60,
DZ = 61,
EC = 62,
EE = 63,
EG = 64,
EH = 65,
ER = 66,
ES = 67,
ET = 68,
FI = 69,
FJ = 70,
FK = 71,
FM = 72,
FO = 73,
FR = 74,
SX = 75,
GA = 76,
GB = 77,
GD = 78,
GE = 79,
GF = 80,
GH = 81,
GI = 82,
GL = 83,
GM = 84,
GN = 85,
GP = 86,
GQ = 87,
GR = 88,
GS = 89,
GT = 90,
GU = 91,
GW = 92,
GY = 93,
HK = 94,
HM = 95,
HN = 96,
HR = 97,
HT = 98,
HU = 99,
ID = 100,
IE = 101,
IL = 102,
IN = 103,
IO = 104,
IQ = 105,
IR = 106,
IS = 107,
IT = 108,
JM = 109,
JO = 110,
JP = 111,
KE = 112,
KG = 113,
KH = 114,
KI = 115,
KM = 116,
KN = 117,
KP = 118,
KR = 119,
KW = 120,
KY = 121,
KZ = 122,
LA = 123,
LB = 124,
LC = 125,
LI = 126,
LK = 127,
LR = 128,
LS = 129,
LT = 130,
LU = 131,
LV = 132,
LY = 133,
MA = 134,
MC = 135,
MD = 136,
MG = 137,
MH = 138,
MK = 139,
ML = 140,
MM = 141,
MN = 142,
MO = 143,
MP = 144,
MQ = 145,
MR = 146,
MS = 147,
MT = 148,
MU = 149,
MV = 150,
MW = 151,
MX = 152,
MY = 153,
MZ = 154,
NA = 155,
NC = 156,
NE = 157,
NF = 158,
NG = 159,
NI = 160,
NL = 161,
NO = 162,
NP = 163,
NR = 164,
NU = 165,
NZ = 166,
OM = 167,
PA = 168,
PE = 169,
PF = 170,
PG = 171,
PH = 172,
PK = 173,
PL = 174,
PM = 175,
PN = 176,
PR = 177,
PS = 178,
PT = 179,
PW = 180,
PY = 181,
QA = 182,
RE = 183,
RO = 184,
RU = 185,
RW = 186,
SA = 187,
SB = 188,
SC = 189,
SD = 190,
SE = 191,
SG = 192,
SH = 193,
SI = 194,
SJ = 195,
SK = 196,
SL = 197,
SM = 198,
SN = 199,
SO = 200,
SR = 201,
ST = 202,
SV = 203,
SY = 204,
SZ = 205,
TC = 206,
TD = 207,
TF = 208,
TG = 209,
TH = 210,
TJ = 211,
TK = 212,
TM = 213,
TN = 214,
TO = 215,
TL = 216,
TR = 217,
TT = 218,
TV = 219,
TW = 220,
TZ = 221,
UA = 222,
UG = 223,
UM = 224,
US = 225,
UY = 226,
UZ = 227,
VA = 228,
VC = 229,
VE = 230,
VG = 231,
VI = 232,
VN = 233,
VU = 234,
WF = 235,
WS = 236,
YE = 237,
YT = 238,
RS = 239,
ZA = 240,
ZM = 241,
ME = 242,
ZW = 243,
A1 = 244,
A2 = 245,
O1 = 249,
AX = 247,
GG = 248,
IM = 249,
JE = 250,
BL = 251,
MF = 252,
BQ = 253,
SS = 254,

Thứ Ba, 24 tháng 1, 2017

Json Schema with Map

{
  "title": "map",
  "type": "object",
  "properties": {},
  "patternProperties": {
    "^[0-9]{1,}$": {
      "type": "integer"
    }
  },
  "additionalProperties": false
}

This code can validate Integer, but cannot check duplicate key.

Chủ Nhật, 31 tháng 1, 2016

Blow game in Unity - Using Microphone

Hi,

This month, I make game like Flappy bird, and using Microphone in Unity.
And now, I write about blow game.

First, I use code from thread: http://forum.unity3d.com/threads/blow-detection-using-ios-microphone.118215/#post-802891

And when use code from post #15, It always crash on android, It use more 1GB ram and crash.


And I fix like #28
/// Starts the Mic, and plays the audio back in (near) real-time.
In AudioSource (I use AudioSource), I set:


private void StartMicListener() {

audio.clip = Microphone.Start(null, true, 1, AudioSettings.outputSampleRate);
// HACK - Forces the function to wait until the microphone has started, before moving onto the play function.
while (!(Microphone.GetPosition(null) > 0)) {
} audio.Play();

}




And, if you need use AudioMixer

Because, when your game recording, the Audiosource will play, and it play with sound in game.

Thanks for reading!!! :D
-- Tuấn Vũ --



Thứ Tư, 25 tháng 11, 2015

Create ipa file using itunes

Create ipa file using itunes

STEP 1: Get .app file
1. xCode window tab
2. Organizer
3. Right click to the archive you want to get app
4. Show in finder
5. Right click to (ProductName….). xcarchive file
6. Show package contents
7. Products/Applications

STEP 2: Create ipa file
1. Drag & drop .app file to itunes profile and binary file.
2. Select app in iTunes and right click to show in Finder. And there you can get the .ipa file.

Source:
http://stackoverflow.com/questions/1984727/how-to-get-app-file-of-a-xcode-application
http://stackoverflow.com/questions/4711586/how-to-make-an-ipa-file

Thứ Tư, 26 tháng 8, 2015

Fix error "clip could not be found in attached animations list"

I have one fbx file with animation. I put new animation to animations list (animation component), but my script could not be found new animation.

And I found solution in there (#11): http://forum.unity3d.com/threads/legacy-animations-dont-work.159980/


I use Unity 5.1.1, I cannot find Animation Type, so, I set my Animaion like below:


I work for me. Goodluck!!! :D
-- Tuan Vu --