To convert ruby unpack equivalent in java -


i'm trying understand line of ruby code:

token.unpack('m0').first.unpack('h*').first 

which converting

r1ykdh//czkubzla09zivzq5/cxinvmokiacnl3mkj0= 

to

47560a747fff7192ae6d9940d3d648559439fdcc489ef9a89080029e5dcc289d 

as far understand this, base64 hex conversion, when try same thing, not matching converted one.

i need implement same functionality in java.

so i'm going break down. first step token.unpack('m0'). according idiosyncratic ruby unpack('m0') decode base64, built-in base64 libararies base64.decode64(string) function. unpack returns arry here, 1 element, converted base64. use token.unpack('m0').first first (and in case only) element of array returned token.unpack('m0'). if all, you'd correct it's base64. but, unpacked base64 unpacked again, time 'h*', convert characters hex. , finally, because return array, use first again make string.

so in summary, happening first string being decoded base64 string, it's being converted hex.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -