package Ġcom . coin ninja . messaging Ċ Ċ import Ġandroid . util . Base 6 4 Ċ import Ġjunit . framework . Assert . assertFalse Ċ import Ġorg . hamcrest . Core Matchers . equalTo Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ Ċ class ĠMessage Crypt or Test Ġ{ ĊĠĠĠ Ġvar Ġmessage Crypt or Ġ= ĠMessage Crypt or () ĊĠĠĠ Ġval Ġencrypted Ġ= ĊĠĠĠĠĠĠĠ Ġ" Aw DV b ES pw T j 3 V ll UN 9 l 4 ig jk Pk 3 p IU ahl OF 3 2 v 2 s Gh j X 7 m 3 v qos / L An ju 3 c PO 8 AR / G UTE 9 x pm qg / ED 0 Ips an Fib 2 BB S 6 An MOS 9 Y + u Gs ED YQ yc HH zc C 7 PP m zu K Dt S da 8 4 2 At SAN Zj gm ++ vr 8 u Ec / b W ac K Q DL +/ Ky L 3 Cu Is + m + ue e jb Bs =" ĊĠĠĠ Ġval Ġencryption Key Base 6 4 Ġ= Ġ" rq c LX f 0 y Hm SH IR ao XO 2 jn D + g V OD r I il 0 w 9 DE Des bz d M =" ĊĠĠĠ Ġval Ġhmac Base 6 4 Ġ= Ġ" Gw X 8 4 8 SP a O 3 qn Op or 6 BN RM Me + Y 8 h 3 R VD z Z f Q jg Uz P / Y =" ĊĠĠĠ Ġval Ġep hemeral PublicKey Base 6 4 Ġ= ĊĠĠĠĠĠĠĠ Ġ" BB S 6 An MOS 9 Y + u Gs ED YQ yc HH zc C 7 PP m zu K Dt S da 8 4 2 At SAN Zj gm ++ vr 8 u Ec / b W ac K Q DL +/ Ky L 3 Cu Is + m + ue e jb Bs =" ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` encryption Ġand Ġde cryption Ġof Ġmessage `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġdata To Encrypt Ġ= Ġ" Hello ĠWorld ". toByteArray () ĊĠĠĠĠĠĠĠ Ġval Ġencryption Key Ġ= Ġ ĠBase 6 4 . decode ( encryption Key Base 6 4 , ĠBase 6 4 . DEFAULT ) ĊĠĠĠĠĠĠĠ Ġval Ġencrypt H mac Ġ= ĠBase 6 4 . decode ( hmac Base 6 4 , ĠBase 6 4 . DEFAULT ) ĊĊĠĠĠĠĠĠĠ Ġval Ġep hemeral PublicKey Ġ= ĠBase 6 4 . decode ( ep hemeral PublicKey Base 6 4 , ĠBase 6 4 . DEFAULT ) ĊĠĠĠĠĠĠĠ Ġval Ġencrypted Ġ= Ġmessage Crypt or . encrypt ( data To Encrypt , Ġencryption Key , Ġencrypt H mac , Ġep hemeral PublicKey ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( ep hemeral PublicKey , ĠequalTo ( encrypted . slice (( encrypted . size - 6 5 ) .. ( encrypted . size - 1 )). toByteArray ())) ĊĊĠĠĠĠĠĠĠ Ġval Ġdecrypted Ġ= Ġmessage Crypt or . decrypt ( encrypted , Ġencryption Key , Ġencrypt H mac ) ĊĠĠĠĠĠĠĠ ĠassertThat ( data To Encrypt , ĠequalTo ( de crypted )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` encryption Ġand Ġde cryption Ġof Ġmessage Ġbase 6 4 Strings `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġdata To Encrypt Ġ= Ġ" Hello ĠWorld ". toByteArray () ĊĠĠĠĠĠĠĠ Ġval Ġencryption Key Ġ= ĠBase 6 4 . decode ( encryption Key Base 6 4 , ĠBase 6 4 . DEFAULT ) ĊĠĠĠĠĠĠĠ Ġval Ġencrypt H mac Ġ= ĠBase 6 4 . decode ( hmac Base 6 4 , ĠBase 6 4 . DEFAULT ) ĊĊĠĠĠĠĠĠĠ Ġval Ġep hemeral PublicKey Ġ= ĠBase 6 4 . decode ( ep hemeral PublicKey Base 6 4 , ĠBase 6 4 . DEFAULT ) ĊĠĠĠĠĠĠĠ Ġval Ġdecoded Ġ= Ġmessage Crypt or . encrypt As Base 6 4 ( data To Encrypt , Ġencryption Key , Ġencrypt H mac , Ġep hemeral PublicKey ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( decoded !!. contains ("\ n ", Ġfalse )); ĊĠĠĠĠĠĠĠ Ġval Ġdecrypted Ġ= Ġmessage Crypt or . decrypt ( decoded , Ġencryption Key , Ġencrypt H mac ) ĊĠĠĠĠĠĠĠ ĠassertThat ( data To Encrypt , ĠequalTo ( de crypted )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Ep hemeral Ġkey Ġfrom Ġencrypted ` (){ ĊĠĠĠĠĠĠĠ Ġval Ġunpack Ep hemeral PublicKey Ġ= Ġmessage Crypt or . unpack Ep hemeral PublicKey ( Base 6 4 . decode ( encrypted , ĠBase 6 4 . DEFAULT )) ĊĠĠĠĠĠĠĠ ĠassertThat ( unpack Ep hemeral PublicKey , ĠequalTo ( Base 6 4 . decode ( ep hemeral PublicKey Base 6 4 , ĠBase 6 4 . DEFAULT ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Ep hemeral Ġkey Ġfrom Ġencrypted Ġstring `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġunpack Ep hemeral PublicKey Ġ= Ġmessage Crypt or . unpack Ep hemeral PublicKey ( encrypted ) ĊĠĠĠĠĠĠĠ ĠassertThat ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġunpack Ep hemeral PublicKey , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠequalTo ( Base 6 4 . decode ( ep hemeral PublicKey Base 6 4 , ĠBase 6 4 . DEFAULT )) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ }