Convert string to base32 php

I have to pass username as an unique string to a webservice, and the API is asking for the following.

  1. Unique string has to be converted to BASE16
  2. It is the BASE16 value I have to pass.

I cannot find a way to convert the value to BASE16. PHP does not seem to have a BASE16_ENCODE like it does for BASE64.

Example:

$value = ;
$base16username = base16_encode['$value']; [< Since Base16_encode does not exist, this is my problem]

Google searches are leading me nowhere, nor is the PHP online manual so I suspect I might be overlooking something obvious. Any suggestions?

base32

Base32 Encoder/Decoder for PHP according to RFC 4648.

Installation

Use composer:

composer require christian-riesen/base32

Usage

simon at simonster dot com

18 years ago

Here are some functions for converting integers to and from base 256. Converting to base 64 is simple given these.



Yes, I know that this would be more efficient if it used mod instead of base_convert, but it needs to work with integers > 32 bits.

fiftytoo at buckeyeexpress dot com

18 years ago

I needed a function to invert a hex value, which i used for setting font colors when they were on a colored background, that way i will get a contrasting color.

Im sure there are other reasons to use this, you decide!!



output: string[3] "314"

bryan at bryanruiz dot com

11 years ago

A RFC 4648 Compliant Base32 encode.  Send me an email if you end up making this thing more efficient with bitwise operations and whatever else.

Chủ Đề