在此示例中(使用 EWS for Exchange 2010 获取组织者的日历约会)我可以从 UID 获取 ID 字符串。但问题是我用 Android 编写的,而不是 C#。所以我需要相同的方法将字符串转换为十六进制数组和 Java 中的 base 64 字符串。我怎么才能得到它?
private static string GetObjectIdStringFromUid( string id )
{
var buffer = new byte[ id.Length / 2 ];
for ( int i = 0; i < id.Length / 2; i++ )
{
var hexValue = byte.Parse( id.Substring( i * 2, 2 ), System.Globalization.NumberStyles.AllowHexSpecifier );
buffer[ i ] = hexValue;
}
return Convert.ToBase64String( buffer );
}
示例输入:
00000000F1985146856BD941BA2343776A64673F0700855A223A9715B6468B4D00795E77CAAB00000033E03A0000855A223A9715B6468B4D00795E760CAAB000000040
输出:
AAAAPGYUUaFa9lBuiNDd2pkZz8HAIVaIjqXFbZGi00AeV53yqsAAAAz4DoAAIVaIjqXFbZGi00AeV53yqsAAAA0hgsAAA==