diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php
index bfa4d76835812719fb3722723691a2101608c586..1cef37baf9f5f12ceb92376eb725f0fd1c8ec42b 100644
--- a/lib/private/files/stream/encryption.php
+++ b/lib/private/files/stream/encryption.php
@@ -303,7 +303,7 @@ class Encryption extends Wrapper {
 
 		$length = 0;
 		// loop over $data to fit it in 6126 sized unencrypted blocks
-		while (strlen($data) > 0) {
+		while (isset($data[0])) {
 			$remainingLength = strlen($data);
 
 			// set the cache to the current 6126 block