summaryrefslogtreecommitdiffstats
path: root/g10/armor.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-02-26 17:59:48 +0100
committerWerner Koch <wk@gnupg.org>1999-02-26 17:59:48 +0100
commit694099b9af96d53ad4a4f9bc70e08c2f393f9f4e (patch)
treeff5ddc557b85093cbf4076374bd43b2e958ce804 /g10/armor.c
parentSee ChangeLog: Thu Feb 25 18:47:39 CET 1999 Werner Koch (diff)
downloadgnupg2-694099b9af96d53ad4a4f9bc70e08c2f393f9f4e.tar.xz
gnupg2-694099b9af96d53ad4a4f9bc70e08c2f393f9f4e.zip
See ChangeLog: Fri Feb 26 17:55:41 CET 1999 Werner Koch
Diffstat (limited to 'g10/armor.c')
-rw-r--r--g10/armor.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/g10/armor.c b/g10/armor.c
index 9cf11c0e0..ce3470398 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -1007,4 +1007,31 @@ armor_filter( void *opaque, int control,
}
+/****************
+ * create a radix64 encoded string.
+ */
+char *
+make_radix64_string( const byte *data, size_t len )
+{
+ char *buffer, *p;
+
+ buffer = p = m_alloc( (len+2)/3*4 + 1 );
+ for( ; len >= 3 ; len -= 3, data += 3 ) {
+ *p++ = bintoasc[(data[0] >> 2) & 077];
+ *p++ = bintoasc[(((data[0] <<4)&060)|((data[1] >> 4)&017))&077];
+ *p++ = bintoasc[(((data[1]<<2)&074)|((data[2]>>6)&03))&077];
+ *p++ = bintoasc[data[2]&077];
+ }
+ if( len == 2 ) {
+ *p++ = bintoasc[(data[0] >> 2) & 077];
+ *p++ = bintoasc[(((data[0] <<4)&060)|((data[1] >> 4)&017))&077];
+ *p++ = bintoasc[((data[1]<<2)&074)];
+ }
+ else if( len == 1 ) {
+ *p++ = bintoasc[(data[0] >> 2) & 077];
+ *p++ = bintoasc[(data[0] <<4)&060];
+ }
+ *p = 0;
+ return buffer;
+}