Introducing Atwood Equipping our ASCII Armor in PHP

I'm trying to implement in PHP something similar to Jeff Atwood Equipping our ASCII armor . Here's the C # Implementing ASCII85 .

Here's the PHP implementation of ASCII85

This is how I convert a string to an array of bytes:

$byteArr = str_split($uid); foreach ($byteArr as $key=>$val) { $byteArr[$key] = ord($val); } 

So what? now :) How to encode this byte array using ASCII 85 to get a shorter UID?

+4
source share
1 answer

It depends on the PHP implementation (your link is not working).

If you use this , then the code is simple:

 <?php include("ascii85.php"); $a = new ASCII85(); $uid = "YOUR-UID-AS-A-STRING"; $en = $a->encode($uid); $de = $a->decode($en); echo $en."\n\n".$de; 
+1
source

Source: https://habr.com/ru/post/1412781/


All Articles